import { IMTableType } from "@/types/table";
import { auditStateMap } from "./dict";
import { ModalFormStateType } from "./type";
export const operateType = ref<any>("");
export const tableActiveKey = ref(0);
export const queryParams = reactive<any>({});
export const defaultColumns = reactive([
  [
    {
      title: getProxyT("base.index"),
      dataIndex: "index",
      key: "index",
    },
    {
      title: getProxyT("table0"),
      key: "userInfo",
    },
    {
      title: getProxyT("table81"),
      dataIndex: "client_avatar",
      key: "client_avatar",
    },
    {
      title: getProxyT("table53"),
      dataIndex: "real_photo",
      key: "real_photo",
    },
    {
      title: getProxyT("table55"),
      dataIndex: "status",
      key: "status",
    },
    {
      title: getProxyT("table52"),
      dataIndex: "created_at",
      key: "created_at",
    },
    {
      title: getProxyT("table44"),
      dataIndex: "updated_at",
      key: "updated_at",
    },
    {
      title: getProxyT("table23"),
      dataIndex: "analysis_name",
      key: "analysis_name",
    },
    {
      title: getProxyT("base.action"),
      key: "action",
    },
  ],
  [],
]);
export const columns = reactive<IMTableType[]>([
  ...defaultColumns[tableActiveKey.value],
]);
export const popularLevelOptions = ref<any>([]);
export const colorOptions = reactive<any>({
  1: "s-ffc107",
  2: "s-52c41a",
  3: "s-dc3545",
  4: "s-c1c1c1",
});
export const defaultSearchList = reactive([
  [
    {
      label: getProxyT("table0"),
      type: "input",
      model: "customer",
      allowClear: true,
      placeholder: getProxyT("placeholder142"),
    },
    {
      label: getProxyT("table55"),
      type: "select",
      model: "status",
      allowClear: true,
      searchClass: "search-item-width-150",
      placeholder: getProxyT("placeholder143"),
      options: auditStateMap,
    },
    {
      label: getProxyT("table52"),
      showTime: { format: "HH:mm:ss" },
      type: "rangePicker",
      model: "start_end_created",
      placeholder: computed(() => [$t("base.startTime"), $t("base.endTime")]),
      format: "YYYY-MM-DD HH:mm:ss",
    },
    {
      label: getProxyT("table23"),
      type: "input",
      model: "analysis_name",
      allowClear: true,
      placeholder: getProxyT("placeholder144"),
    },
    {
      label: getProxyT("table44"),
      showTime: { format: "HH:mm:ss" },
      type: "rangePicker",
      model: "start_end_updated",
      placeholder: computed(() => [$t("base.startTime"), $t("base.endTime")]),
      format: "YYYY-MM-DD HH:mm:ss",
    },
  ],
  [],
]);
export const searchList = ref<any>(defaultSearchList[tableActiveKey.value]);
export const drawerInstance = ref<any>(null);
export const drawer_disable_ok_button = ref(false);
export const modalTitle = ref("");
export const modalVisible = ref(false);
export const modalFormState = reactive<ModalFormStateType>({
  editId: undefined,
  level: undefined,
  real_person_id: undefined,
  reason: undefined,
});
export const modalInstance = ref<any>(null);
export const modalLoading = ref(false);
export const modal_disable_ok_button = computed(() => {
  return operateType.value === "markLevel" && isEmptyType(modalFormState.level);
});
